import service from '@/utils/axios';
import { IResponseType, PageVO } from '@/api/common';
import {
    CategoryAddRO,
    CategoryEditRO,
    CategoryPageRO,
    CategoryVO
} from '@/api/content/category/category';

export const getCategoryInfo = (id: string) => {
    return service<IResponseType<CategoryVO>>({
        url: '/content/category/get/' + id,
        method: 'post'
    });
};

export const getCategoryAll = async () => {
    return service<IResponseType<PageVO<CategoryVO>>>({
        url: '/content/category/page',
        method: 'post',
        data: {
            current: 1,
            size: 1000
        }
    });
};

export const getCategoryPage = (pageRO: CategoryPageRO) => {
    return service<IResponseType<PageVO<CategoryVO>>>({
        url: '/content/category/page',
        method: 'post',
        data: pageRO
    });
};

export const addCategory = (data: CategoryAddRO) => {
    return service<IResponseType<void>>({
        url: '/content/category/add',
        method: 'post',
        data
    });
};

export const editCategory = (data: CategoryEditRO) => {
    return service<IResponseType<void>>({
        url: '/content/category/edit',
        method: 'post',
        data
    });
};

export const remove = (ids: string) => {
    return service<IResponseType<void>>({
        url: '/content/category/remove/' + ids,
        method: 'post'
    });
};